import { InjectionToken, container } from "tsyringe"
import { SENDER } from "../tokens"
/**
 * websocket 信息发送
 * WEBSOCKET_EMIT 发送消息给服务器
 * WEBSOCKET_CONSOLE_EMIT 发送日志给服务器
 */
export function sendToWebsocket<T>(payload: { type: string | InjectionToken<T>, payload: T }) {
    const sender = container.resolve(SENDER)
    sender.emit(`WEBSOCKET_EMIT`, payload)
}
export function sendToWebView<T>(payload: { type: string | InjectionToken<T>, payload: T }) {
    const sender = container.resolve(SENDER)
    sender.emit(`WEBVIEW_EMIT`, payload)
}
/**
 * 工具库
 */
export function setGlobal<T = any>(key: string, val: T) {
    global.key = val;
}
export function getGlobal<T = any>(key: string) {
    return global.KeyCode;
}